
<!DOCTYPE html>
<html lang="zh-Hans" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Html5 - 默默默默燃</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="TriDiamond Obsidian,"> 
    <meta name="description" content="一枚前端搬砖队队员的记录册,html5特性用于媒介回放的 video 和 audio 元素Video支持的视频格式Ogg = 带有 Theora 视频编码和 Vorbis 音频编码的 Ogg 文件（.ogg）
MPEG4 = ,"> 
    <meta name="author" content="张白告丶"> 
    <link rel="alternative" href="atom.xml" title="默默默默燃" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon.png"> 
    <link href="https://fonts.loli.net/css?family=Roboto+Mono|Rubik&display=swap" rel="stylesheet">
    
<link rel="stylesheet" href="//at.alicdn.com/t/font_1429596_nzgqgvnmkjb.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.7.2/animate.min.css">

    
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/codemirror/5.48.4/codemirror.min.css">

    
<link rel="stylesheet" href="//cdn.bootcss.com/codemirror/5.48.4/theme/dracula.css">

    
<link rel="stylesheet" href="/css/obsidian.css">

    
<link rel="stylesheet" href="/css/ball-atom.min.css">

<meta name="generator" content="Hexo 4.2.0"></head>


<body class="loading">
    <div class="loader">
        <div class="la-ball-atom la-2x">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <span id="config-title" style="display:none">默默默默燃</span>
    <div id="loader"></div>
    <div id="single">
    <div class="scrollbar gradient-bg-rev"></div>
<div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <div class="navigation animated fadeIn fast delay-1s">
        <img id="home-icon" class="icon-home" src="/img/favicon.png" alt="" data-url="https://zhanghao-web.github.io">
        <div id="play-icon" title="Play/Pause" class="iconfont icon-play"></div>
        <h3 class="subtitle">Html5</h3>
        <div class="social">
            <!--        <div class="like-icon">-->
            <!--            <a href="javascript:;" class="likeThis active"><span class="icon-like"></span><span class="count">76</span></a>-->
            <!--        </div>-->
            <div>
                <div class="share">
                    
                        <a href="javascript:;" class="iconfont icon-share1"></a>
                        <div class="share-component-cc" data-disabled="facebook,douban,linkedin,diandian,tencent,google"></div>
                    
                </div>
            </div>
        </div>
    </div>
</div>

    <div class="section">
        <div class=article-header-wrapper>
    <div class="article-header">
        <div class="article-cover animated fadeIn" style="
            animation-delay: 600ms;
            animation-duration: 1.2s;
            background-image: 
                radial-gradient(ellipse closest-side, rgba(0, 0, 0, 0.65), #100e17),
                url(/img/cover.jpg) ">
        </div>
        <div class="else">
            <p class="animated fadeInDown">
                
                <a href="/categories/HTML5"><b>「
                    </b>HTML5<b> 」</b></a>
                
                March 19, 2018
            </p>
            <h3 class="post-title animated fadeInDown"><a href="/2018/03/19/HTML5/Html5/" title="Html5" class="">Html5</a>
            </h3>
            
            <p class="post-count animated fadeInDown">
                
                <span>
                    <b class="iconfont icon-text2"></b> <i>Words count</i>
                    32k
                </span>
                
                
                <span>
                    <b class="iconfont icon-timer__s"></b> <i>Reading time</i>
                    29 mins.
                </span>
                
                
                
                <span id="busuanzi_container_page_pv">
                    <b class="iconfont icon-read"></b> <i>Read count</i>
                    <span id="busuanzi_value_page_pv">0</span>
                </span>
                
            </p>
            
            
            <ul class="animated fadeInDown post-tags-list" itemprop="keywords"><li class="animated fadeInDown post-tags-list-item"><a class="animated fadeInDown post-tags-list-link" href="/tags/HTML5/" rel="tag">HTML5</a></li></ul>
            
        </div>
    </div>
</div>

<div class="screen-gradient-after">
    <div class="screen-gradient-content">
        <div class="screen-gradient-content-inside">
            <div class="bold-underline-links screen-gradient-sponsor">
                <p>
                    <span class="animated fadeIn delay-1s"></span>
                </p>
            </div>
        </div>
    </div>
</div>

<div class="article">
    <div class='main'>
        <div class="content markdown animated fadeIn">
            <h1 id="html5特性"><a href="#html5特性" class="headerlink" title="html5特性"></a>html5特性</h1><h2 id="用于媒介回放的-video-和-audio-元素"><a href="#用于媒介回放的-video-和-audio-元素" class="headerlink" title="用于媒介回放的 video 和 audio 元素"></a>用于媒介回放的 video 和 audio 元素</h2><h3 id="Video"><a href="#Video" class="headerlink" title="Video"></a>Video</h3><h4 id="支持的视频格式"><a href="#支持的视频格式" class="headerlink" title="支持的视频格式"></a>支持的视频格式</h4><p>Ogg = 带有 Theora 视频编码和 Vorbis 音频编码的 Ogg 文件（.ogg）</p>
<p>MPEG4 = 带有 H.264 视频编码和 AAC 音频编码的 MPEG 4 文件(.mp4)</p>
<p>WebM = 带有 VP8 视频编码和 Vorbis 音频编码的 WebM 文件(.mkv)</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">video</span> <span class="attr">src</span>=<span class="string">"movie.ogg"</span> <span class="attr">controls</span>=<span class="string">"controls"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">video</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><strong>controls</strong> 属性供添加播放、暂停和音量控件。</p>
<p>包含宽度和高度属性也是不错的主意。<br>如果有不支持video的浏览器器则使用下面代码<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">video</span> <span class="attr">src</span>=<span class="string">"movie.ogg"</span> <span class="attr">width</span>=<span class="string">"320"</span> <span class="attr">height</span>=<span class="string">"240"</span> <span class="attr">controls</span>=<span class="string">"controls"</span>&gt;</span></span><br><span class="line">Your browser does not support the video tag.</span><br><span class="line"><span class="tag">&lt;/<span class="name">video</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>video 元素允许多个 source 元素。source 元素可以链接不同的视频文件。浏览器将使用第一个可识别的格式：<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">video</span> <span class="attr">width</span>=<span class="string">"320"</span> <span class="attr">height</span>=<span class="string">"240"</span> <span class="attr">controls</span>=<span class="string">"controls"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">source</span> <span class="attr">src</span>=<span class="string">"movie.ogg"</span> <span class="attr">type</span>=<span class="string">"video/ogg"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">source</span> <span class="attr">src</span>=<span class="string">"movie.mp4"</span> <span class="attr">type</span>=<span class="string">"video/mp4"</span>&gt;</span></span><br><span class="line">  Your browser does not support the video tag.</span><br><span class="line"><span class="tag">&lt;/<span class="name">video</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>IE8不支持video元素，在 IE 9 中，将提供对使用 MPEG4 的 video 元素的支持。</p>
<h4 id="video标签属性："><a href="#video标签属性：" class="headerlink" title="video标签属性："></a>video标签属性：</h4><p>autoplay 自动播放<br>controls 显示控件<br>width 设置播放器的宽度<br>height 设置播放器高度<br>loop  如果设置为True则循环播放<br>preload 如果出现该属性，则视频在页面加载时进行加载，并预备播放。如果使用 “autoplay”，则忽略该属性。<br>src 要播放的视频的 URL</p>
<h4 id="video方法，属性及事件："><a href="#video方法，属性及事件：" class="headerlink" title="video方法，属性及事件："></a>video方法，属性及事件：</h4><p>paly() 视频播放<br>pasue() 视频暂停<br>load()  视频加载</p>
<h3 id="audio"><a href="#audio" class="headerlink" title="audio"></a>audio</h3><h4 id="audio支持的音频格式"><a href="#audio支持的音频格式" class="headerlink" title="audio支持的音频格式"></a>audio支持的音频格式</h4><p>Ogg Vorbis （.ogg）<br>Mp3 (.mp3)<br>Wav (.wav)</p>
<h4 id="audio标签的属性"><a href="#audio标签的属性" class="headerlink" title="audio标签的属性"></a>audio标签的属性</h4><p>autoplay 自动播放<br>controls 音频控件<br>loop 循环播放<br>preload 如果出现该属性，则视频在页面加载时进行加载，并预备播放。如果使用 “autoplay”，则忽略该属性。<br>src 要播放的音频的 URL</p>
<h2 id="html5拖放（drag和drop"><a href="#html5拖放（drag和drop" class="headerlink" title="html5拖放（drag和drop)"></a>html5拖放（drag和drop)</h2><a id="more"></a>
<h3 id="浏览器支持"><a href="#浏览器支持" class="headerlink" title="浏览器支持"></a>浏览器支持</h3><p>Internet Explorer 9、Firefox、Opera 12、Chrome 以及 Safari 5 支持拖放。</p>
<p>注释：在 Safari 5.1.2 中不支持拖放。</p>
<p>一个简单地例子<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">HTML</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">"text/javascript"</span>&gt;</span></span><br><span class="line"><span class="actionscript"><span class="function"><span class="keyword">function</span> <span class="title">allowDrop</span><span class="params">(ev)</span></span>&#123;</span></span><br><span class="line">    ev.preventDefault();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript"><span class="function"><span class="keyword">function</span> <span class="title">drag</span><span class="params">(ev)</span></span>&#123;</span></span><br><span class="line"><span class="actionscript">    ev.dataTransfer.setData(<span class="string">"Text"</span>,ev.target.id);</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="actionscript"><span class="function"><span class="keyword">function</span> <span class="title">drop</span><span class="params">(ev)</span></span>&#123;</span></span><br><span class="line">    ev.preventDefault();</span><br><span class="line"><span class="actionscript">    <span class="keyword">var</span> data=ev.dataTransfer.getData(<span class="string">"Text"</span>);</span></span><br><span class="line"><span class="javascript">    ev.target.appendChild(<span class="built_in">document</span>.getElementById(data));</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"div1"</span> <span class="attr">ondrop</span>=<span class="string">"drop(event)"</span></span></span><br><span class="line"><span class="tag"><span class="attr">ondragover</span>=<span class="string">"allowDrop(event)"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">id</span>=<span class="string">"drag1"</span> <span class="attr">src</span>=<span class="string">"img_logo.gif"</span> <span class="attr">draggable</span>=<span class="string">"true"</span></span></span><br><span class="line"><span class="tag"><span class="attr">ondragstart</span>=<span class="string">"drag(event)"</span> <span class="attr">width</span>=<span class="string">"336"</span> <span class="attr">height</span>=<span class="string">"69"</span> /&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="设置元素为可拖放"><a href="#设置元素为可拖放" class="headerlink" title="设置元素为可拖放"></a>设置元素为可拖放</h3><p>首先，为了使元素可拖动，把 draggable 属性设置为 true ：<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">draggable</span>=<span class="string">"true"</span> /&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="拖动什么-ondragstart-和-setData"><a href="#拖动什么-ondragstart-和-setData" class="headerlink" title="拖动什么 - ondragstart 和 setData()"></a>拖动什么 - ondragstart 和 setData()</h3><p>然后，规定当元素被拖动时，会发生什么。<br>在上面的例子中，ondragstart 属性调用了一个函数，drag(event)，它规定了被拖动的数据。<br>dataTransfer.setData() 方法设置被拖数据的数据类型和值：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">drag</span>(<span class="params">ev</span>)</span>&#123;</span><br><span class="line">    ev.dataTransfer.setData(<span class="string">"Text"</span>,ev.target.id);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在这个例子中，数据类型是 “Text”，值是可拖动元素的 id (“drag1”)。</p>
<h3 id="放到何处-ondragover"><a href="#放到何处-ondragover" class="headerlink" title="放到何处 - ondragover"></a>放到何处 - ondragover</h3><p>ondragover 事件规定在何处放置被拖动的数据。</p>
<p>默认地，无法将数据/元素放置到其他元素中。如果需要设置允许放置，我们必须阻止对元素的默认处理方式。</p>
<p>这要通过调用 ondragover 事件的 event.preventDefault() 方法：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">event.preventDefault()</span><br></pre></td></tr></table></figure></p>
<h3 id="进行放置-ondrop"><a href="#进行放置-ondrop" class="headerlink" title="进行放置 - ondrop"></a>进行放置 - ondrop</h3><p>当放置被拖数据时，会发生 drop 事件。</p>
<p>在上面的例子中，ondrop 属性调用了一个函数，drop(event)：</p>
<p>function drop(ev)<br>{<br>ev.preventDefault();<br>var data=ev.dataTransfer.getData(“Text”);<br>ev.target.appendChild(document.getElementById(data));<br>}</p>
<blockquote>
<p>代码解释：<br>1.调用 preventDefault() 来避免浏览器对数据的默认处理（drop 事件的默认行为是以链接形式打开）<br>2.通过 dataTransfer.getData(“Text”) 方法获得被拖的数据。该方法将返回在 setData() 方法中设置为相同类型的任何数据。<br>3.被拖数据是被拖元素的 id (“drag1”)<br>4.把被拖元素追加到放置元素（目标元素）中</p>
</blockquote>
<h2 id="Canvas-画布"><a href="#Canvas-画布" class="headerlink" title="Canvas(画布)"></a>Canvas(画布)</h2><h3 id="什么是-Canvas？"><a href="#什么是-Canvas？" class="headerlink" title="什么是 Canvas？"></a>什么是 Canvas？</h3><p>HTML5 的 canvas 元素使用 JavaScript 在网页上绘制图像。</p>
<p>画布是一个矩形区域，您可以控制其每一像素。<br>canvas 拥有多种绘制路径、矩形、圆形、字符以及添加图像的方法。</p>
<h3 id="创建-Canvas-元素"><a href="#创建-Canvas-元素" class="headerlink" title="创建 Canvas 元素"></a>创建 Canvas 元素</h3><p>向 HTML5 页面添加 canvas 元素。</p>
<p>规定元素的 id、宽度和高度：<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">"myCanvas"</span> <span class="attr">width</span>=<span class="string">"200"</span> <span class="attr">height</span>=<span class="string">"100"</span>&gt;</span><span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="通过-JavaScript-来绘制"><a href="#通过-JavaScript-来绘制" class="headerlink" title="通过 JavaScript 来绘制"></a>通过 JavaScript 来绘制</h3><p>canvas 元素本身是没有绘图能力的。所有的绘制工作必须在 JavaScript 内部完成：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span>&gt;</span><br><span class="line"><span class="keyword">var</span> c=<span class="built_in">document</span>.getElementById(<span class="string">"myCanvas"</span>);</span><br><span class="line"><span class="keyword">var</span> cxt=c.getContext(<span class="string">"2d"</span>);</span><br><span class="line">cxt.fillStyle=<span class="string">"#FF0000"</span>;</span><br><span class="line">cxt.fillRect(<span class="number">0</span>,<span class="number">0</span>,<span class="number">150</span>,<span class="number">75</span>);</span><br><span class="line">&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></table></figure><br>JavaScript 使用 id 来寻找 canvas 元素：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> c=<span class="built_in">document</span>.getElementById(<span class="string">"myCanvas"</span>);</span><br></pre></td></tr></table></figure><br>然后，创建 context 对象：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> cxt=c.getContext(<span class="string">"2d"</span>); </span><br><span class="line">getContext(<span class="string">"2d"</span>) 对象是内建的 HTML5 对象，拥有多种绘制路径、矩形、圆形、字符以及添加图像的方法。</span><br></pre></td></tr></table></figure><br>下面的两行代码绘制一个红色的矩形：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cxt.fillStyle=<span class="string">"#FF0000"</span>;</span><br><span class="line">cxt.fillRect(<span class="number">0</span>,<span class="number">0</span>,<span class="number">150</span>,<span class="number">75</span>);</span><br></pre></td></tr></table></figure><br>fillStyle 方法将其染成红色，fillRect 方法规定了形状、位置和尺寸。</p>
<h2 id="SVG"><a href="#SVG" class="headerlink" title="SVG"></a>SVG</h2><h3 id="什么是SVG？"><a href="#什么是SVG？" class="headerlink" title="什么是SVG？"></a>什么是SVG？</h3><p>SVG 指可伸缩矢量图形 (Scalable Vector Graphics)<br>SVG 用于定义用于网络的基于矢量的图形<br>SVG 使用 XML 格式定义图形<br>SVG 图像在放大或改变尺寸的情况下其图形质量不会有损失<br>SVG 是万维网联盟的标准</p>
<h3 id="SVG-的优势"><a href="#SVG-的优势" class="headerlink" title="SVG 的优势"></a>SVG 的优势</h3><p>与其他图像格式相比（比如 JPEG 和 GIF），使用 SVG 的优势在于：</p>
<p>SVG 图像可通过文本编辑器来创建和修改<br>SVG 图像可被搜索、索引、脚本化或压缩<br>SVG 是可伸缩的<br>SVG 图像可在任何的分辨率下被高质量地打印<br>SVG 可在图像质量不下降的情况下被放大</p>
<h3 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">svg</span> <span class="attr">xmlns</span>=<span class="string">"http://www.w3.org/2000/svg"</span> <span class="attr">version</span>=<span class="string">"1.1"</span> <span class="attr">height</span>=<span class="string">"190"</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">polygon</span> <span class="attr">points</span>=<span class="string">"100,10 40,180 190,60 10,60 160,180"</span></span></span><br><span class="line"><span class="tag">  <span class="attr">style</span>=<span class="string">"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">svg</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="Canvas-与-SVG-的比较"><a href="#Canvas-与-SVG-的比较" class="headerlink" title="Canvas 与 SVG 的比较"></a>Canvas 与 SVG 的比较</h2><p>下表列出了 canvas 与 SVG 之间的一些不同之处。</p>
<blockquote>
<p>Canvas<br>    依赖分辨率<br>    不支持事件处理器<br>    弱的文本渲染能力<br>    能够以 .png 或 .jpg 格式保存结果图像<br>    最适合图像密集型的游戏，其中的许多对象会被频繁重绘</p>
<p>SVG<br>    不依赖分辨率<br>    支持事件处理器<br>    最适合带有大型渲染区域的应用程序（比如谷歌地图）<br>    复杂度高会减慢渲染速度（任何过度使用 DOM 的应用都不快）<br>    不适合游戏应用</p>
</blockquote>
<h2 id="Html5地理定位"><a href="#Html5地理定位" class="headerlink" title="Html5地理定位"></a>Html5地理定位</h2><p>HTML5 Geolocation API 用于获得用户的地理位置。</p>
<p>鉴于该特性可能侵犯用户的隐私，除非用户同意，否则用户位置信息是不可用的。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line"><span class="keyword">var</span> x=<span class="built_in">document</span>.getElementById(<span class="string">"demo"</span>);</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getLocation</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">  </span>&#123;</span><br><span class="line">  <span class="keyword">if</span> (navigator.geolocation)</span><br><span class="line">    &#123;</span><br><span class="line">    navigator.geolocation.getCurrentPosition(showPosition);</span><br><span class="line">    &#125;</span><br><span class="line">  <span class="keyword">else</span>&#123;x.innerHTML=<span class="string">"Geolocation is not supported by this browser."</span>;&#125;</span><br><span class="line">  &#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">showPosition</span>(<span class="params">position</span>)</span></span><br><span class="line"><span class="function">  </span>&#123;</span><br><span class="line">  x.innerHTML=<span class="string">"Latitude: "</span> + position.coords.latitude +</span><br><span class="line">  <span class="string">"&lt;br /&gt;Longitude: "</span> + position.coords.longitude;</span><br><span class="line">  &#125;</span><br><span class="line">&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></table></figure></p>
<blockquote>
<p>上面代码解释：<br>检测是否支持地理定位<br>如果支持，则运行 getCurrentPosition() 方法。如果不支持，则向用户显示一段消息。<br>如果getCurrentPosition()运行成功，则向参数showPosition中规定的函数返回一个coordinates对象<br>showPosition() 函数获得并显示经度和纬度</p>
</blockquote>
<p>处理错误：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">showError</span>(<span class="params">error</span>)</span></span><br><span class="line"><span class="function">  </span>&#123;</span><br><span class="line">  <span class="keyword">switch</span>(error.code)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> error.PERMISSION_DENIED:<span class="comment">// 用户不允许地理定位</span></span><br><span class="line">      x.innerHTML=<span class="string">"User denied the request for Geolocation."</span></span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> error.POSITION_UNAVAILABLE:<span class="comment">//无法获取当前位置</span></span><br><span class="line">      x.innerHTML=<span class="string">"Location information is unavailable."</span></span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> error.TIMEOUT:<span class="comment">// 超时处理</span></span><br><span class="line">      x.innerHTML=<span class="string">"The request to get user location timed out."</span></span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> error.UNKNOWN_ERROR: <span class="comment">// 错误处理</span></span><br><span class="line">      x.innerHTML=<span class="string">"An unknown error occurred."</span></span><br><span class="line">      <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></p>
<h2 id="HTML-5-Web-存储"><a href="#HTML-5-Web-存储" class="headerlink" title="HTML 5 Web 存储"></a>HTML 5 Web 存储</h2><p>HTML5 提供了两种在客户端存储数据的新方法：</p>
<p>localStorage - 没有时间限制的数据存储<br>sessionStorage - 针对一个 session 的数据存储</p>
<h3 id="localStorage-方法"><a href="#localStorage-方法" class="headerlink" title="localStorage 方法"></a>localStorage 方法</h3><p>localStorage 方法存储的数据没有时间限制。第二天、第二周或下一年之后，数据依然可用。</p>
<p>如何创建和访问 localStorage：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span>&gt;</span><br><span class="line">localStorage.lastname=<span class="string">"Smith"</span>;</span><br><span class="line"><span class="built_in">document</span>.write(localStorage.lastname);</span><br><span class="line">&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="sessionStorage-方法"><a href="#sessionStorage-方法" class="headerlink" title="sessionStorage 方法"></a>sessionStorage 方法</h3><p>sessionStorage 方法针对一个 session 进行数据存储。当用户关闭浏览器窗口后，数据会被删除。</p>
<p>如何创建并访问一个 sessionStorage：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span>&gt;</span><br><span class="line">sessionStorage.lastname=<span class="string">"Smith"</span>;</span><br><span class="line"><span class="built_in">document</span>.write(sessionStorage.lastname);</span><br><span class="line">&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></table></figure></p>
<h2 id="HTML-5-应用程序缓存"><a href="#HTML-5-应用程序缓存" class="headerlink" title="HTML 5 应用程序缓存"></a>HTML 5 应用程序缓存</h2><h3 id="什么是应用程序缓存（Application-Cache）？"><a href="#什么是应用程序缓存（Application-Cache）？" class="headerlink" title="什么是应用程序缓存（Application Cache）？"></a>什么是应用程序缓存（Application Cache）？</h3><p>HTML5 引入了应用程序缓存，这意味着 web 应用可进行缓存，并可在没有因特网连接时进行访问。</p>
<blockquote>
<p>应用程序缓存为应用带来三个优势：</p>
</blockquote>
<p>离线浏览 - 用户可在应用离线时使用它们<br>速度 - 已缓存资源加载得更快<br>减少服务器负载 - 浏览器将只从服务器下载更新过或更改过的资源。</p>
<h3 id="Cache-Manifest-基础"><a href="#Cache-Manifest-基础" class="headerlink" title="Cache Manifest 基础"></a>Cache Manifest 基础</h3><p>如需启用应用程序缓存，请在文档的 <html> 标签中包含 manifest 属性：<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">HTML</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">manifest</span>=<span class="string">"demo.appcache"</span>&gt;</span></span><br><span class="line">...</span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h3 id="Manifest-文件"><a href="#Manifest-文件" class="headerlink" title="Manifest 文件"></a>Manifest 文件</h3><p>manifest 文件是简单的文本文件，它告知浏览器被缓存的内容（以及不缓存的内容）。</p>
<p>manifest 文件可分为三个部分：</p>
<p><em>CACHE MANIFEST</em> - 在此标题下列出的文件将在首次下载后进行缓存<br><em>NETWORK</em> - 在此标题下列出的文件需要与服务器的连接，且不会被缓存<br><em>FALLBACK</em> - 在此标题下列出的文件规定当页面无法访问时的回退页面（比如 404 页面）</p>
<h3 id="更新缓存"><a href="#更新缓存" class="headerlink" title="更新缓存"></a>更新缓存</h3><p>一旦应用被缓存，它就会保持缓存直到发生下列情况：</p>
<p>用户清空浏览器缓存<br>manifest 文件被修改（参阅下面的提示）<br>由程序来更新应用缓存</p>
<h3 id="实例-完整的-Manifest-文件"><a href="#实例-完整的-Manifest-文件" class="headerlink" title="实例 - 完整的 Manifest 文件"></a>实例 - 完整的 Manifest 文件</h3><p>CACHE MANIFEST</p>
<p> #2012-02-21 v1.0.0<br>/theme.css<br>/logo.gif<br>/main.js</p>
<p>NETWORK:<br>login.asp</p>
<p>FALLBACK:<br>/html5/ /404.html</p>
<p><font color = "red">重要的提示：</font>以 “#” 开头的是注释行，但也可满足其他用途。应用的缓存会在其 manifest 文件更改时被更新。如果您编辑了一幅图片，或者修改了一个 JavaScript 函数，这些改变都不会被重新缓存。更新注释行中的日期和版本号是一种使浏览器重新缓存文件的办法。</p>
<p>注释：浏览器对缓存数据的容量限制可能不太一样（某些浏览器设置的限制是每个站点 5MB）。</p>
<h2 id="HTML-5-Web-Workers"><a href="#HTML-5-Web-Workers" class="headerlink" title="HTML 5 Web Workers"></a>HTML 5 Web Workers</h2><p>什么是 Web Worker？<br>当在 HTML 页面中执行脚本时，页面的状态是不可响应的，直到脚本已完成。</p>
<p>web worker 是运行在后台的 JavaScript，独立于其他脚本，不会影响页面的性能。您可以继续做任何愿意做的事情：点击、选取内容等等，而此时 web worker 在后台运行。</p>
<blockquote>
<p>Web Workers 和 DOM<br>由于 web worker 位于外部文件中，它们无法访问下例 JavaScript 对象：<br>window 对象<br>document 对象<br>parent 对象</p>
</blockquote>
<h2 id="HTML-5-服务器发送事件"><a href="#HTML-5-服务器发送事件" class="headerlink" title="HTML 5 服务器发送事件"></a>HTML 5 服务器发送事件</h2><p>Server-Sent 事件 - 单向消息传递<br>Server-Sent 事件指的是网页自动获取来自服务器的更新。</p>
<p>以前也可能做到这一点，前提是网页不得不询问是否有可用的更新。通过服务器发送事件，更新能够自动到达。</p>
<p>例子：Facebook/Twitter 更新、估价更新、新的博文、赛事结果等<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> source=<span class="keyword">new</span> EventSource(<span class="string">"demo_sse.php"</span>);</span><br><span class="line">source.onmessage=<span class="function"><span class="keyword">function</span>(<span class="params">event</span>)</span></span><br><span class="line"><span class="function">  </span>&#123;</span><br><span class="line">  <span class="built_in">document</span>.getElementById(<span class="string">"result"</span>).innerHTML+=event.data + <span class="string">"&lt;br /&gt;"</span>;</span><br><span class="line">  &#125;;</span><br></pre></td></tr></table></figure><br>EventSource 对象<br>在上面的例子中，我们使用 onmessage 事件来获取消息。不过还可以使用其他事件：</p>
<p>onopen    当通往服务器的连接被打开<br>onmessage    当接收到消息<br>onerror    当错误发生</p>
<h2 id="html5表单"><a href="#html5表单" class="headerlink" title="html5表单"></a>html5表单</h2><p>HTML5 新的 Input 类型<br>HTML5 拥有多个新的表单输入类型。这些新特性提供了更好的输入控制和验证。</p>
<p>本章全面介绍这些新的输入类型：</p>
<p>email 在提交表单时，会自动验证 email 域的值。<br>url 在提交表单时，会自动验证 url 域的值。<br>number number类型用于应该包含数值的输入域。<br>range range 类型显示为滑动条。<br>Date pickers (date, month, week, time, datetime, datetime-local) 日期选择器<br>search 搜索域，比如站点搜索或 Google 搜索。<br>color </p>
<h2 id="HTML5-表单元素"><a href="#HTML5-表单元素" class="headerlink" title="HTML5 表单元素"></a>HTML5 表单元素</h2><blockquote>
<p>HTML5 的新的表单元素：<br>datalist datalist 元素规定输入域的选项列表。<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Webpage: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"url"</span> <span class="attr">list</span>=<span class="string">"url_list"</span> <span class="attr">name</span>=<span class="string">"link"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">datalist</span> <span class="attr">id</span>=<span class="string">"url_list"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">option</span> <span class="attr">label</span>=<span class="string">"W3School"</span> <span class="attr">value</span>=<span class="string">"http://www.W3School.com.cn"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">option</span> <span class="attr">label</span>=<span class="string">"Google"</span> <span class="attr">value</span>=<span class="string">"http://www.google.com"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">option</span> <span class="attr">label</span>=<span class="string">"Microsoft"</span> <span class="attr">value</span>=<span class="string">"http://www.microsoft.com"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">datalist</span>&gt;</span></span><br></pre></td></tr></table></figure><br>提示：option 元素永远都要设置 value 属性。</p>
</blockquote>
<p>keygen keygen 元素的作用是提供一种验证用户的可靠方法。<br>output output 元素用于不同类型的输出，比如计算或脚本输出：</p>
<h2 id="HTML5-表单属性"><a href="#HTML5-表单属性" class="headerlink" title="HTML5 表单属性"></a>HTML5 表单属性</h2><h3 id="新的-form-属性："><a href="#新的-form-属性：" class="headerlink" title="新的 form 属性："></a>新的 form 属性：</h3><p>autocomplete autocomplete 属性规定 form 或 input 域应该拥有自动完成功能。<br>novalidate</p>
<h3 id="新的-input-属性："><a href="#新的-input-属性：" class="headerlink" title="新的 input 属性："></a>新的 input 属性：</h3><p>autocomplete<br>autofocus autofocus 属性规定在页面加载时，域自动地获得焦点。<br>form<br>form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget) 允许您重写 form 元素的某些属性设定<br>height 和 width height 和 width 属性规定用于 image 类型的 input 标签的图像高度和宽度。<br>list list 属性规定输入域的 datalist。datalist 是输入域的选项列表。<br>min, max 和 step step 属性为输入域规定合法的数字间隔<br>multiple multiple 属性适用于以下类型的 <input> 标签：email 和 file。<br>pattern (regexp) pattern 属性规定用于验证 input 域的模式（pattern）。<br>placeholder 属性提供一种提示（hint），描述输入域所期待的值。<br>required  属性规定必须在提交之前填写输入域（不能为空）。</p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls"
                data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
            <ul id="audio-list" style="display:none">
                
                
                <li title='0' data-url='/statics/chengdu.mp3'></li>
                
                    
            </ul>
            
            
            
    <div id='gitalk-container' class="comment link"
        data-ae='true'
        data-ci='ec894e2b66f752e8b7fb'
        data-cs='3ccc2e92bb350688fe2c2dc2930189b62622bfb1'
        data-r='blog-comments'
        data-o='TriDiamond'
        data-a='TriDiamond'
        data-d='undefined'
    >Comments</div>


            
            
        </div>
        <div class="sidebar">
            <div class="box animated fadeInRight">
                <div class="subbox">
                    <img src="https://res.cloudinary.com/tridiamond/image/upload/v1573019751/TriDiamond_logo_ui_xeublz.jpg" height=300 width=300></img>
                    <p>张白告丶</p>
                    <span>Think like an artist, develop like an artisan</span>
                    <dl>
                        <dd><a href="https://github.com/zhanghao-web" target="_blank"><span
                                    class=" iconfont icon-github"></span></a></dd>
                        <dd><a href="" target="_blank"><span
                                    class=" iconfont icon-twitter"></span></a></dd>
                        <dd><a href="" target="_blank"><span
                                    class=" iconfont icon-stack-overflow"></span></a></dd>
                    </dl>
                </div>
                <ul>
                    <li><a href="/">149 <p>Articles</p></a></li>
                    <li><a href="/categories">23 <p>Categories</p></a></li>
                    <li><a href="/tags">47 <p>Tags</p></a></li>
                </ul>
            </div>
            
            
            
            <div class="box sticky animated fadeInRight faster">
                <div id="toc" class="subbox">
                    <h4>Contents</h4>
                    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#html5特性"><span class="toc-number">1.</span> <span class="toc-text">html5特性</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#用于媒介回放的-video-和-audio-元素"><span class="toc-number">1.1.</span> <span class="toc-text">用于媒介回放的 video 和 audio 元素</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Video"><span class="toc-number">1.1.1.</span> <span class="toc-text">Video</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#audio"><span class="toc-number">1.1.2.</span> <span class="toc-text">audio</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#html5拖放（drag和drop"><span class="toc-number">1.2.</span> <span class="toc-text">html5拖放（drag和drop)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#浏览器支持"><span class="toc-number">1.2.1.</span> <span class="toc-text">浏览器支持</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#设置元素为可拖放"><span class="toc-number">1.2.2.</span> <span class="toc-text">设置元素为可拖放</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#拖动什么-ondragstart-和-setData"><span class="toc-number">1.2.3.</span> <span class="toc-text">拖动什么 - ondragstart 和 setData()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#放到何处-ondragover"><span class="toc-number">1.2.4.</span> <span class="toc-text">放到何处 - ondragover</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#进行放置-ondrop"><span class="toc-number">1.2.5.</span> <span class="toc-text">进行放置 - ondrop</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Canvas-画布"><span class="toc-number">1.3.</span> <span class="toc-text">Canvas(画布)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#什么是-Canvas？"><span class="toc-number">1.3.1.</span> <span class="toc-text">什么是 Canvas？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#创建-Canvas-元素"><span class="toc-number">1.3.2.</span> <span class="toc-text">创建 Canvas 元素</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#通过-JavaScript-来绘制"><span class="toc-number">1.3.3.</span> <span class="toc-text">通过 JavaScript 来绘制</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SVG"><span class="toc-number">1.4.</span> <span class="toc-text">SVG</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#什么是SVG？"><span class="toc-number">1.4.1.</span> <span class="toc-text">什么是SVG？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SVG-的优势"><span class="toc-number">1.4.2.</span> <span class="toc-text">SVG 的优势</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#例子"><span class="toc-number">1.4.3.</span> <span class="toc-text">例子</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Canvas-与-SVG-的比较"><span class="toc-number">1.5.</span> <span class="toc-text">Canvas 与 SVG 的比较</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Html5地理定位"><span class="toc-number">1.6.</span> <span class="toc-text">Html5地理定位</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML-5-Web-存储"><span class="toc-number">1.7.</span> <span class="toc-text">HTML 5 Web 存储</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#localStorage-方法"><span class="toc-number">1.7.1.</span> <span class="toc-text">localStorage 方法</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#sessionStorage-方法"><span class="toc-number">1.7.2.</span> <span class="toc-text">sessionStorage 方法</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML-5-应用程序缓存"><span class="toc-number">1.8.</span> <span class="toc-text">HTML 5 应用程序缓存</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#什么是应用程序缓存（Application-Cache）？"><span class="toc-number">1.8.1.</span> <span class="toc-text">什么是应用程序缓存（Application Cache）？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Cache-Manifest-基础"><span class="toc-number">1.8.2.</span> <span class="toc-text">Cache Manifest 基础</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Manifest-文件"><span class="toc-number">1.8.3.</span> <span class="toc-text">Manifest 文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#更新缓存"><span class="toc-number">1.8.4.</span> <span class="toc-text">更新缓存</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#实例-完整的-Manifest-文件"><span class="toc-number">1.8.5.</span> <span class="toc-text">实例 - 完整的 Manifest 文件</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML-5-Web-Workers"><span class="toc-number">1.9.</span> <span class="toc-text">HTML 5 Web Workers</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML-5-服务器发送事件"><span class="toc-number">1.10.</span> <span class="toc-text">HTML 5 服务器发送事件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#html5表单"><span class="toc-number">1.11.</span> <span class="toc-text">html5表单</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML5-表单元素"><span class="toc-number">1.12.</span> <span class="toc-text">HTML5 表单元素</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#HTML5-表单属性"><span class="toc-number">1.13.</span> <span class="toc-text">HTML5 表单属性</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#新的-form-属性："><span class="toc-number">1.13.1.</span> <span class="toc-text">新的 form 属性：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#新的-input-属性："><span class="toc-number">1.13.2.</span> <span class="toc-text">新的 input 属性：</span></a></li></ol></li></ol></li></ol>
                </div>
            </div>
            
            
        </div>
    </div>
</div>

    </div>
</div>
    <div id="back-to-top" class="animated fadeIn faster">
        <div class="flow"></div>
        <span class="percentage animated fadeIn faster">0%</span>
        <span class="iconfont icon-top02 animated fadeIn faster"></span>
    </div>
</body>
<footer>
    <p class="copyright" id="copyright">
        &copy; 2020
        <span class="gradient-text">
            张白告丶
        </span>.
        Powered by <a href="http://hexo.io/" title="Hexo" target="_blank" rel="noopener">Hexo</a>
        Theme
        <span class="gradient-text">
            <a href="https://github.com/TriDiamond/hexo-theme-obsidian" title="Obsidian" target="_blank" rel="noopener">Obsidian</a>
        </span>
        <small><a href="https://github.com/TriDiamond/hexo-theme-obsidian/blob/master/CHANGELOG.md" title="v1.4.3" target="_blank" rel="noopener">v1.4.3</a></small>
    </p>
</footer>

<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script>
  MathJax.Hub.Config({
    "HTML-CSS": {
      preferredFont: "TeX",
      availableFonts: ["STIX", "TeX"],
      linebreaks: {
        automatic: true
      },
      EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
    },
    tex2jax: {
      inlineMath: [
        ["$", "$"],
        ["\\(", "\\)"]
      ],
      processEscapes: true,
      ignoreClass: "tex2jax_ignore|dno",
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
      noUndefined: {
        attributes: {
          mathcolor: "red",
          mathbackground: "#FFEEEE",
          mathsize: "90%"
        }
      },
      Macros: {
        href: "{}"
      }
    },
    messageStyle: "none"
  });
</script>
<script>
  function initialMathJax() {
    MathJax.Hub.Queue(function () {
      var all = MathJax.Hub.getAllJax(),
        i;
      // console.log(all);
      for (i = 0; i < all.length; i += 1) {
        console.log(all[i].SourceElement().parentNode)
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
    });
  }

  function reprocessMathJax() {
    if (typeof MathJax !== 'undefined') {
      MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
    }
  }
</script>



    
<link rel="stylesheet" href="//cdn.bootcss.com/gitalk/1.5.0/gitalk.min.css">

    
<script src="//cdn.bootcss.com/gitalk/1.5.0/gitalk.min.js"></script>



<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/obsidian.js"></script>
<script src="/js/jquery.truncate.js"></script>
<script src="/js/search.js"></script>


<script src="//cdn.bootcss.com/typed.js/2.0.10/typed.min.js"></script>


<script src="//cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script>


<script src="//cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>


<script src="https://cdn.bootcss.com/codemirror/5.48.4/codemirror.min.js"></script>

    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/javascript/javascript.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/css/css.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/xml/xml.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/htmlmixed/htmlmixed.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/clike/clike.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/php/php.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/shell/shell.min.js"></script>


    
<script src="//cdn.bootcss.com/codemirror/5.48.4/mode/python/python.min.js"></script>




    
<script src="/js/busuanzi.min.js"></script>

    <script>
        $(document).ready(function () {
            if ($('span[id^="busuanzi_"]').length) {
                initialBusuanzi();
            }
        });
    </script>



<link rel="stylesheet" href="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="//cdn.bootcss.com/photoswipe/4.1.3/default-skin/default-skin.min.css">


<script src="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="//cdn.bootcss.com/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>



    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="//www.googletagmanager.com/gtag/js?id=UA-149874671-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', 'UA-149874671-1');
    </script>





<script>
    function initialTyped () {
        var typedTextEl = $('.typed-text');
        if (typedTextEl && typedTextEl.length > 0) {
            var typed = new Typed('.typed-text', {
                strings: ["Think like an artist, develop like an artisan", "艺术家思维去思考问题，工匠创造精神去开发"],
                typeSpeed: 90,
                loop: true,
                loopCount: Infinity,
                backSpeed: 20,
            });
        }
    }

    if ($('.article-header') && $('.article-header').length) {
        $(document).ready(function () {
            initialTyped();
        });
    }
</script>




</html>
